package com.daocheng.weblog.web.convert;

import com.daocheng.weblog.common.domain.dos.ArticleDO;
import com.daocheng.weblog.web.model.vo.archive.FindArchiveArticleRspVO;
import com.daocheng.weblog.web.model.vo.article.FindIndexArticlePageListRspVO;
import com.daocheng.weblog.web.model.vo.category.FindCategoryArticlePageListRspVO;
import com.daocheng.weblog.web.model.vo.tag.FindTagArticlePageListRspVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @ClassName ArticleConvert
 * @author: 稻城
 * @date: 2025/3/12
 * @Version 1.0
 * @description: TODO
 */
@Mapper
public interface ArticleConvert {
    /**
     * 初始化 convert 实例
     */
    ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);

    /**
     * @param bean
     * @return FindIndexArticlePageListRspVO
     * @author 稻城
     * @Date 2025/3/15 2:44
     * @description 将 DO 转化为 VO
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindIndexArticlePageListRspVO convertDO2VO(ArticleDO bean);

    /**
     * @param bean
     * @return FindArchiveArticleRspVO
     * @author 稻城
     * @Date 2025/3/15 2:44
     * @description 将 DO 转化为归档文章 VO
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    @Mapping(target = "createMonth", expression = "java(java.time.YearMonth.from(bean.getCreateTime()))")
    FindArchiveArticleRspVO convertDO2ArchiveArticleVO(ArticleDO bean);

    /**
     * @param bean
     * @return FindCategoryArticlePageListRspVO
     * @author 稻城
     * @Date 2025/3/15 2:44
     * @description DO转VO
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindCategoryArticlePageListRspVO convertDO2CategoryArticleVO(ArticleDO bean);

    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindTagArticlePageListRspVO convertDO2TagArticleVO(ArticleDO bean);
}
